package com.leo.apptest.activity;

import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

/**
 * Created by zhangguobao on 2016/12/1.
 */
public class DecelerateAccelerateInterpolator implements Interpolator {
    final float factor;

    public DecelerateAccelerateInterpolator() {
        this(1);
    }

    public DecelerateAccelerateInterpolator(float factor) {
        this.factor = factor;
    }

    public float getInterpolation(float t) {
        if (t < 0.5f) {
            return new DecelerateInterpolator(factor).getInterpolation(2 * t);
        } else {
            return new AccelerateInterpolator(factor).getInterpolation(2 * (t - 0.5f));
        }
    }
}
